# TODO: Add comment
# 
# Author: rbergande
###############################################################################

retMA <- function(x,ma){
			n <- length(x)
			n.out <- n-ma+1
			out <- rep(0,n.out)
			if(ma>1){
				for(i in 1:n.out){
					out[i] <- t(x[i:(i+ma-2)])%*%(1:(ma-1))/ma
				}
			}
			out
}


ret
x <- ret

optimizeOverN <- 36
ma.max <- length(x)-optimizeOverN
opt <- rep(NA,ma.max)
for(i in 1:ma.max){
	# i <-28
	maData <- retMA(x[(length(x)-optimizeOverN-i+1):length(x)],i)[1:optimizeOverN]
	retX <- sign(maData) * x[(length(x)-optimizeOverN+1):length(x)]
	opt[i] <- mean(retX)/sd(retX)
}
